package com.firmail.enumeration.impl;

import com.firmail.enumeration.MockParamsEnum;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Getter
public enum MockTypeEnum implements MockParamsEnum {


    MOCK_GET(1, "GET"), MOCK_POST(2, "POST"),

    MOCK_PUT(3, "PUT"), MOCK_DELETE(4, "DELETE"),

    MOCK_OPTIONS(3, "OPTIONS"), MOCK_TRACE(4, "TRACE");


    // 成员变量
    private int value;
    private String name;

    private MockTypeEnum(int value, String name) {
        this.name = name;
        this.value = value;
    }

    // 普通方法
    public static String getName(int value) {
        for (MockTypeEnum mt : MockTypeEnum.values()) {
            if (mt.getValue() == value) {
                return mt.name;
            }
        }
        return null;
    }
    /**
     * 根据value返回枚举类型,主要在switch中使用
     */
    public static MockTypeEnum getByValue(int value) {
        for (MockTypeEnum type : values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        return null;
    }

    @Override
    public void print() {
        log.info("{} :{}", this.value, this.name);
    }

    @Override
    public String getInfo() {
        return this.name;
    }
}
